<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="试卷名称" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入试卷名称" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="试卷状态" prop="state">
        <el-select v-model="queryParams.state" placeholder="试卷状态" clearable
                   @keyup.enter.native="handleQuery">
          <el-option
            v-for="item in options.EXAM_TEST_PAPER_STATE.list"
            v-bind="item"
            :key="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="考试计划" prop="exemPlanId">
        <el-select v-model="queryParams.exemPlanId" placeholder="请输入考试计划" clearable filterable
                  @keyup.enter.native="handleQuery">
          <el-option
            v-for="item in options.examPlanList"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="试卷模板" prop="testPaperModuleId">
        <el-select v-model="queryParams.testPaperModuleId" placeholder="请输入试卷模板" clearable filterable
                   @keyup.enter.native="handleQuery">
      <el-option
        v-for="item in options.testPaperModuleList"
        :label="item.name"
        :value="item.id"
        :key="item.id"
      />
        </el-select>
      </el-form-item>
      <el-form-item label="人员" prop="userId">
        <el-select v-model="queryParams.userId" placeholder="请输入人员" clearable filterable @keyup.enter.native="handleQuery">
          <el-option
            v-for="item in options.userList"
            :label="item.nickName"
            :value="item.userId"
            :key="item.userId"
          />
        </el-select>
      </el-form-item>
      <!--      <el-form-item label="提交时间" prop="submitTime">-->
      <!--        <el-date-picker clearable v-model="queryParams.submitTime" type="date" value-format="yyyy-MM-dd"-->
      <!--          placeholder="请选择试卷提交时间">-->
      <!--        </el-date-picker>-->
      <!--      </el-form-item>-->
      <el-form-item label="用户部门" prop="deptId">
        <dept-selector v-model="queryParams.deptId" placeholder="请输入考试时用户部门" clearable filterable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="用户岗位" prop="postId">
        <post-selector v-model="queryParams.postId" placeholder="请输入考试时用户岗位" clearable filterable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="岗位能力" prop="postLevelCode">
        <el-select v-model="queryParams.postLevelCode" placeholder="请输入考试时用户岗位能力" clearable
                  @keyup.enter.native="handleQuery">
          <el-option
            v-for="item in dict.type.post_level"
            v-bind="item"
            :key="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['train:ExamTestPaper:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['train:ExamTestPaper:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['train:ExamTestPaper:remove']">删除</el-button>
      </el-col> -->
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
                   v-hasPermi="['train:ExamTestPaper:export']">导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table border v-loading="loading" :data="ExamTestPaperList" @selection-change="handleSelectionChange">
      <el-table-column resizable show-overflow-tooltip type="selection" width="55" align="center"/>
      <!-- <el-table-column resizable show-overflow-tooltip label="主键" align="center" prop="id" /> -->
      <el-table-column resizable show-overflow-tooltip label="考试计划" align="center" prop="examPlanName"/>
      <el-table-column resizable show-overflow-tooltip label="试卷名称" align="center" prop="name"/>
      <el-table-column resizable show-overflow-tooltip label="试卷模板" align="center" prop="testPaperModuleName"/>
      <el-table-column resizable show-overflow-tooltip label="人员" align="center" prop="userName"/>
      <el-table-column resizable show-overflow-tooltip label="总数量" align="center" prop="questionNum"/>
      <el-table-column resizable show-overflow-tooltip label="正答数量" align="center" prop="rightAnswerNum"/>
      <el-table-column resizable show-overflow-tooltip label="未做数量" align="center" prop="notDoneNum"/>
      <el-table-column resizable show-overflow-tooltip label="模糊数量" align="center" prop="vagueNum"/>
      <el-table-column resizable show-overflow-tooltip label="试卷状态" align="center" prop="stateStr"/>
      <el-table-column resizable show-overflow-tooltip label="提交时间" align="center" prop="submitTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.submitTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column resizable show-overflow-tooltip label="用户部门" align="center" prop="deptName"/>
      <el-table-column resizable show-overflow-tooltip label="用户岗位" align="center" prop="postName"/>
      <el-table-column resizable show-overflow-tooltip label="岗位能力" align="center" prop="postLevelCode"/>
      <el-table-column resizable show-overflow-tooltip label="试卷总分数" align="center" prop="grade"/>
      <el-table-column resizable show-overflow-tooltip label="用户得分" align="center" prop="gainGrade"/>
      <el-table-column resizable label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-receiving" @click="receive(scope.row)"
                     v-if="scope.row.state === options.EXAM_TEST_PAPER_STATE.enums.WAIT_RECEIVE.value && scope.row.userId === currentUserId">
            领取
          </el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleReply(scope.row)"
                     v-if="scope.row.state === options.EXAM_TEST_PAPER_STATE.enums.WAIT_SUBMIT.value && scope.row.userId === currentUserId">
            答题
          </el-button>
          <el-button size="mini" type="text" icon="el-icon-s-check" @click="handleGrade(scope.row)"
                     v-if="scope.row.state === options.EXAM_TEST_PAPER_STATE.enums.WAIT_GRADE.value" v-hasPermi="['train:ExamTestPaper:remark']">判卷
          </el-button>
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)"
                     v-if="scope.row.state === options.EXAM_TEST_PAPER_STATE.enums.FINISH.value">查看
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>
  </div>
</template>


<script src="./index.js">
</script>
